<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>【补交】项目4 | 邵吹水的博客</title>
    <meta property="og:title" content="【补交】项目4 - 邵吹水的博客">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2021-01-05T16:34:11&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2021-01-05T16:34:11&#43;08:00'>
        
    <meta name="Keywords" content="中山大学,shaozhd,吹水,软件工程,C语言,Wikipedia,博客">
    <meta name="description" content="【补交】项目4">
        
    <meta name="author" content="shaozhd">
    <meta property="og:url" content="https://shaozhd.gitee.io/post/project4/">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

    <link rel="stylesheet" href='/css/normalize.css'>
    <link rel="stylesheet" href='/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
    
    
    
        <link rel="stylesheet" href='/css/douban.css'>
    
        <link rel="stylesheet" href='/css/other.css'>
    
</head>


<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://shaozhd.gitee.io">
                        邵吹水的博客
                    </a>
                
                <p class="description">一点儿都不想做学渣的软工本科小邵同学</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://shaozhd.gitee.io">首页</a>
                    
                    <a  href="https://shaozhd.gitee.io/homework/" title="作业">作业</a>
                    
                    <a  href="https://shaozhd.gitee.io/archives/" title="归档">归档</a>
                    
                    <a  href="https://shaozhd.gitee.io/about/" title="关于">关于</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#一pcir-寄存器的作用">一、PC，IR 寄存器的作用。</a></li>
    <li><a href="#二acc-寄存器的全称与作用">二、ACC 寄存器的全称与作用。</a></li>
    <li><a href="#三用lod-3指令的执行过程解释fetch-execute周期">三、用“LOD #3”指令的执行过程，解释Fetch-Execute周期。</a></li>
    <li><a href="#四用add-w-指令的执行过程解释fetch-execute周期">四、用“ADD W” 指令的执行过程，解释Fetch-Execute周期。</a></li>
    <li><a href="#五lod-3-与-add-w-指令的执行在fetch-execute周期级别有什么不同">五、“LOD #3” 与 “ADD W” 指令的执行在Fetch-Execute周期级别，有什么不同。</a></li>
  </ul>

  <ul>
    <li><a href="#一输入程序program-2运行并回答问题">一、输入程序Program 2，运行并回答问题</a></li>
    <li><a href="#二修改该程序用机器语言实现-10981-输出结果存放于内存-y">二、修改该程序，用机器语言实现 10+9+8+..1 ，输出结果存放于内存 Y</a></li>
  </ul>
</nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">【补交】项目4</h1>
        </header>
        <date class="post-meta meta-date">
            2021年1月5日
        </date>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <h1 id="任务-1简单程序">任务 1：简单程序</h1>
<h2 id="一pcir-寄存器的作用">一、PC，IR 寄存器的作用。</h2>
<ol>
<li>PC: PC是专门用于在CPU取指令期间寻址程序存储器。PC总是保存着下一条要执行的指令的16位地址。</li>
<li>IR:
<ul>
<li>用来存放后续指令地址</li>
<li>保存当前正在执行的一条指令</li>
<li>保存将被存储的下一个数据字节的地址</li>
<li>保存当前CPU所访问的主存单元的地址</li>
</ul>
</li>
</ol>
<h2 id="二acc-寄存器的全称与作用">二、ACC 寄存器的全称与作用。</h2>
<ol>
<li>全称:Accumulator</li>
<li>主要用于完成数据的算术和逻辑运算，可以存放数据或中间结果。</li>
</ol>
<h2 id="三用lod-3指令的执行过程解释fetch-execute周期">三、用“LOD #3”指令的执行过程，解释Fetch-Execute周期。</h2>
<p>PC 根据地址从RAM取出指令LOD #3 -&gt; 指令传入IR，指令传入Decoder，无需取址，数字3传入MUX -&gt; 数字3传入ALU -&gt; 传入ACC</p>
<h2 id="四用add-w-指令的执行过程解释fetch-execute周期">四、用“ADD W” 指令的执行过程，解释Fetch-Execute周期。</h2>
<p>PC从RAM取出指令&quot;ADD W&rdquo; -&gt; 将指令传入IR -&gt; 传入Decoder -&gt; ALU从ACC中取值 -&gt; IR再次访问RAM中的W，从W中取值 -&gt; ALU读取W的值 -&gt; ALU执行加法 -&gt; 结果传入ACC</p>
<h2 id="五lod-3-与-add-w-指令的执行在fetch-execute周期级别有什么不同">五、“LOD #3” 与 “ADD W” 指令的执行在Fetch-Execute周期级别，有什么不同。</h2>
<p>LOD #3，访问RAM一次</p>
<p>ADD W，两次访问RAM</p>
<ol>
<li>写出指令 “LOD #7” 的二进制形式，按指令结构，解释每部分的含义。 00010100(步骤) 00000111（操作数）</li>
<li>解释 RAM 的地址。 用于临时存放程序和数据，关闭电源或发生断电后，程序和数据就会丢失</li>
<li>该机器CPU是几位的？（按累加器的位数） 16位</li>
<li>写出该程序对应的 C语言表达 int w = 3; int x = 7; int z = x + w;</li>
</ol>
<h1 id="任务-2简单循环">任务 2：简单循环</h1>
<h2 id="一输入程序program-2运行并回答问题">一、输入程序Program 2，运行并回答问题</h2>
<ol>
<li>用一句话总结程序的功能 x从10开始每次递减1，知道x小于0 2.写出对应的 c 语言程序 int x = 10; while (x &gt;= 0){ x–; }</li>
</ol>
<h2 id="二修改该程序用机器语言实现-10981-输出结果存放于内存-y">二、修改该程序，用机器语言实现 10+9+8+..1 ，输出结果存放于内存 Y</h2>
<ol>
<li>写出 c 语言的计算过程 int x = 10; int tmp = 0; while(x &gt; 0){ tmp+=x; x–; } int Y = tmp;</li>
<li>写出机器语言的计算过程</li>
</ol>
<pre><code>0000000 00010100 00001010 0000010 00000101 10000001 0000100 00010001 00000001 0000110 00000101 10000000 0001000 00000000 10000001 0001010 00000101 10000000 0001100 00000100 10000000 0001110 00001101 00010010 0010000 00001100 00000100 0010010 00000101 10000010 0010100 00001111 00000000 0010110 00001110 00000000 1000000 00000000 1000001 00000000 1000010 00000000 
</code></pre><ol start="3">
<li>用自己的语言，简单总结高级语言与机器语言的区别与联系。 联系:高级语言通过编译可转变为机械语言 区别：高级语言是人类使用的语言，机器语言是机器使用的语言</li>
</ol>
<p>实验小结</p>
<ol>
<li>机器语言与高级语言的区别和联系及其相互转换；</li>
<li>观察CPU的运行情况，熟悉内部结构；</li>
<li>指令格式、周期格式等；</li>
</ol>

        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://shaozhd.gitee.io">shaozhd</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://shaozhd.gitee.io/post/project4/">https://shaozhd.gitee.io/post/project4/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://zh.wikipedia.org/wiki/%e5%85%b1%e4%ba%a7%e4%b8%bb%e4%b9%89">我自己看一遍的方法</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/post/wiki10/">【补交】作业10</a></li>
        
        <li><a href="/post/wiki8/">【补交】作业8</a></li>
        
        <li><a href="/post/wiki9/">【补交】作业9</a></li>
        
        <li><a href="/post/project5/">【补交】项目5</a></li>
        
        <li><a href="/post/project6/">【补交】项目6</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            没有标签
            
        </div>
    </article>
    
    <div id="disqus_thread"></div>
<script type="application/javascript">
    var disqus_config = function () {
    
    
    
    };
    (function() {
        if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
            document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
            return;
        }
        var d = document, s = d.createElement('script'); s.async = true;
        s.src = '//' + "yourdiscussshortname" + '.disqus.com/embed.js';
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

    
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2021 <a href="https://shaozhd.gitee.io">邵吹水的博客 By shaozhd</a>
        
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://gohugo.io/" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">Hugo</span></a>
        </div>
        <div class="github-badge">
            <a href="https://www.flysnow.org/" target="_black"><span class="badge-subject">Design by</span><span class="badge-value bg-brightgreen">飞雪无情</span></a>
        </div>
        <div class="github-badge">
            <a href="https://github.com/flysnow-org/maupassant-hugo" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">Maupassant</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/js/totop.js?v=0.0.0' async=""></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/js/douban.js'></script>


                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://shaozhd.gitee.io/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://shaozhd.gitee.io">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki10/" title="【补交】作业10">【补交】作业10</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki8/" title="【补交】作业8">【补交】作业8</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki9/" title="【补交】作业9">【补交】作业9</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project4/" title="【补交】项目4">【补交】项目4</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project5/" title="【补交】项目5">【补交】项目5</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project6/" title="【补交】项目6">【补交】项目6</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project7/" title="【补交】项目7">【补交】项目7</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project9/" title="项目9：字符游戏-智能蛇">项目9：字符游戏-智能蛇</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/project8/" title="项目8：字符游戏-贪吃蛇">项目8：字符游戏-贪吃蛇</a>
    </li>
    
    <li>
        <a href="https://shaozhd.gitee.io/post/wiki7/" title="使用维基百科(Wikipedia)解释名词VII及其解答题">使用维基百科(Wikipedia)解释名词VII及其解答题</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title"><a href="/categories">分类</a></h3>
<ul class="widget-list">
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href="/tags">标签</a></h3>
<div class="tagcloud">
    
</div>
    </section>

    

    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://shaozhd.gitee.io/index.xml">文章 RSS</a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
</body>

</html>